import request from '@/utils/request'

export function login(data) {
  return request({
    url: 'user/login',
    method: 'post',
    data
  })
}

export function changePassword(data) {
  return request({
    url: 'user/changePassword',
    method: 'post',
    data
  })
}

export function createUser(data) {
  return request({
    url: 'user/create',
    method: 'post',
    data
  })
}

export function updateUser(data) {
  return request({
    url: 'user/update',
    method: 'post',
    data
  })
}

export function deleteUser(data) {
  return request({
    url: 'user/delete',
    method: 'post',
    data
  })
}

export function getInfo() {
  return request({
    url: '/user/info',
    method: 'post',
    // params: { token }
  })
}

export function logout() {
  return request({
    url: '/user/logout',
    method: 'post'
  })
}

export function fetchList(query) {
  return request({
    url: '/user/info/list',
    method: 'get',
    params: query
  })
}

export function getCaptcha() {
  return request({
    url: '/user/captcha',
    method: 'get',
    // headers: {
    //   responseType: 'blob'
    //   // emulateJSON: true
    // }
    responseType: 'arraybuffer'
  })
}
